import 'package:flutter/material.dart';
import 'package:industry_net/base/common/util.dart';
import 'package:industry_net/pages/msg/chat/chat/widgets/config.dart';
import 'package:industry_net/pages/msg/chat/models/chat.dart';

class ChatImageCell extends StatelessWidget {
  const ChatImageCell({Key? key, required this.md}) : super(key: key);
  final ChatModel md;
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(md.isSelf ? ChatConfig.contentOffx : gap12,
          gap10, md.isSelf ? gap12 : ChatConfig.contentOffx, 0),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment:
            md.isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
        children: md.isSelf ? _getItems().reversed.toList() : _getItems(),
      ),
    );
  }

  List<Widget> _getItems() {
    return [
      loadAvater(size: 40.r),
      SizedBox(
        width: 5.r,
      ),
      Flexible(
        child: Container(
          margin: EdgeInsets.only(top: ChatConfig.contentOffy),
          // padding: ChatConfig.textPadding,
          child: ClipRRect(
            borderRadius: BorderRadius.only(
              topLeft: md.isSelf ? ChatConfig.radius : Radius.zero,
              topRight: md.isSelf ? Radius.zero : ChatConfig.radius,
              bottomLeft: ChatConfig.radius,
              bottomRight: ChatConfig.radius,
            ),
            child: loadImage(),
          ),
          // alignment: Alignment.centerLeft,
        ),
      ),
    ];
  }
}
